package com.liu.boot.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author QS.Liu
 * @date 2020/6/29/13:47
 */
@Configuration  //xml
public class ElastriSearchConfig {
    @Bean
    public RestHighLevelClient restHighLevelClient(){
        //集群的话配置多个HttpHost
        RestHighLevelClient client = new RestHighLevelClient(
                RestClient.builder(
                new HttpHost("localhost",9200,"http"),
                new HttpHost("localhost",9201,"http")
                )
        );
        return client;
    }
}
